
<ul>
    <?php $i=0; foreach($this->getPosts() as $post): $i++; ?>

    <?php
    Yii::app()->clientScript->registerScript('archive'.$i, "
    $('.year-link$i').click(function(){
            $('.month-link$i').toggle();
            return false;
    });
    ");
    ?>

        <?php $year=date('Y',$post->create_time); ?>
        <strong style="font-size:11pt">
        <?php echo CHtml::link(CHtml::image('images/folder.gif').' '.$year,'#',array('class'=>'year-link'.$i,'style'=>'text-decoration:none')); ?>
        </strong><br>
        <div class="month-link<?php echo $i;?>" style="display:none">
            <?php foreach($this->getPosts2($year) as $post2): ?>
                <?php $month=date('n',$post2->create_time); ?>
            <li>
                &nbsp;&nbsp;&nbsp;&nbsp;<?php echo CHtml::link(CHtml::image('images/page.gif').' '.CHtml::encode(date('F',$post2->create_time)).' ('.$this->countPosts($year,$month).')', array('post/index','year'=>$year,'month'=>$month),
                            array('style'=>'text-decoration:none') ); ?>
                </li>
            <?php endforeach; ?>
        </div>   
    <?php endforeach; ?>
</ul>
